function setPng(img, w, h){
    var ua = window.navigator.userAgent.toLowerCase();
    if (!/msie/.test(ua))
        return;
    imgStyle = "display:inline-block;" + img.style.cssText;
    strNewHTML = "";
    img.outerHTML = strNewHTML;
}

function loginLayerCenter() {
	
	var bodyWidth = $("body").css("width").replace("px","");
	var loginLayerWidth = $(".login-layer").css("width").replace("px", "");
	var leftOffset = parseInt(bodyWidth)/2 - parseInt(loginLayerWidth)/2;
	var shadowOffset = leftOffset - 12;
	$(".login-layer").css("left", leftOffset + "px");
	$(".login-shadow").css("left", shadowOffset + "px");
}

function regLayerCenter() {
	var bodyWidth = $("body").css("width").replace("px","");
	var regLayerWidth = $(".reg-layer").css("width").replace("px", "");
	var leftOffset = parseInt(bodyWidth)/2 - parseInt(regLayerWidth)/2;
	var shadowOffset = leftOffset - 12;
	$(".reg-layer").css("left", leftOffset + "px");
	$(".reg-shadow").css("left", shadowOffset + "px");
}

$(function() {
	/****** login and register js */
	var windowHeight = document.documentElement.clientHeight;
	var bodyHeight = $("body").css("height").replace("px", "");
	if(parseInt(windowHeight) > parseInt(bodyHeight)) { 
		bodyHeight = windowHeight;
	}
	$(".login-layer-shade").css("height", bodyHeight + "px");
	$(".reg-layer-shade").css("height", bodyHeight + "px");
	
	loginLayerCenter();
	regLayerCenter();
	window.onresize = loginLayerCenter;
	$(window).bind("resize", regLayerCenter);
	
	$('.login-close-button, .login-button, .reg-button, .reg, .reg-close-button').hover(function() {
		$(this).addClass('ui-state-hover');
	}, function() {
		$(this).removeClass('ui-state-hover');
	});
	
	$(".reg-link, .login-link").bind("mouseover", function(){ $(this).addClass("reg-login-hover") });
	$(".reg-link, .login-link").bind("mouseout", function(){ $(this).removeClass("reg-login-hover") });
	
	/* login-layer popup event */
	$(".login-link").bind("click", function() {
		$(".login-layer-shade").show();
		$(".login-layer").show(500);
	});
	
	/* login-layer close event */
	$(".login-layer .login-close-button").bind("click", function() {
		$(".login-layer").hide(500);
		$(".login-layer-shade").hide();
		return false;
	});
	
	/* reg-layer popup event */
	$(".reg-link").bind("click", function() {
		$(".reg-layer-shade").show();
		$(".reg-layer").show(500);
	});
	
	/* reg-layer close event */
	$(".reg-layer .reg-close-button").bind("click", function() {
		$(".reg-layer").hide(500);
		$(".reg-layer-shade").hide();
		return false;
	});
	
	$(".reg-button").bind("click", function() {
		$(".login-layer").slideUp(500);
		setTimeout(function(){
			$(".login-layer-shade").hide();
			$(".reg-layer-shade").show();
			$(".reg-layer").slideDown(500);
		}, 500);
		
	});
	
	/****** login and register js  end */
});